import React, { Component } from 'react'
// 1. 导入 prop-types
import PropTypes from 'prop-types'
export default class PropsTypeCom extends Component {
  // 2-1. 设置属性值的约束规则
  static propTypes = {
    name: PropTypes.string.isRequired, //require 必须
    age: PropTypes.number,
    gender: PropTypes.string
  }
  //2-2. 设置属性的默认值  default 默认的 prop 属性
  static defaultProps = {
    name: '某人'
  }

  render() {
    let {name, age, gender} = this.props;
    return (
      <ul>
        <li>姓名: {name}</li>
        <li>年龄: {age}</li>
        <li>性别: {gender}</li>
      </ul>
    )
  }
}
